package br.unip.tcc.domotic.orm;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

@Entity
@Table(name = "evento")
public class Event extends AbstractORM {
	
	private static final long serialVersionUID = 1L;
	
	private Integer eventId;
	private String eventName;
	private Boolean eventActive;
	private Set<Condition> conditions = new HashSet<Condition>(0);
	private Set<Action> actions = new HashSet<Action>(0);
	
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "cod_evento", unique = true, nullable = false)
	public Integer getEventId() {
		return eventId;
	}
	
	public void setEventId(Integer eventId) {
		this.eventId = eventId;
	}
	
	@Column(name = "nom_evento", nullable = false)
	public String getEventName() {
		return eventName;
	}
	
	public void setEventName(String eventName) {
		this.eventName = eventName;
	}
	
	@Column(name = "flg_habilitado", nullable = false)
	public Boolean getEventActive() {
		return eventActive;
	}
	
	public void setEventActive(Boolean eventActive) {
		this.eventActive = eventActive;
	}
	
	@ManyToMany(fetch = FetchType.LAZY)
	@JoinTable(name = "acoes_evento", 
		joinColumns = { @JoinColumn(name = "cod_evento", nullable = false, updatable =  false) }, 
		inverseJoinColumns = { @JoinColumn(name = "cod_condicao", nullable = false, updatable = false) })
	public Set<Condition> getConditions() {
		return conditions;
	}
	
	public void setConditions(Set<Condition> conditions) {
		this.conditions = conditions;
	}
	
	@ManyToMany(fetch = FetchType.LAZY)
	@JoinTable(name = "acoes_evento", 
		joinColumns = { @JoinColumn(name = "cod_evento", nullable = false, updatable =  false) }, 
		inverseJoinColumns = { @JoinColumn(name = "cod_acao", nullable = false, updatable = false) })
	public Set<Action> getActions() {
		return actions;
	}
	
	public void setActions(Set<Action> actions) {
		this.actions = actions;
	}
	
}
